package com.luhaoran.hrm.controller;

import com.alibaba.fastjson.JSONObject;
import com.luhaoran.hrm.entity.User;
import com.luhaoran.hrm.service.IUserService;
import com.luhaoran.hrm.utils.TokenUtils;
import com.luhaoran.hrm.utils.ViewUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Date;


/**
 * @author haoranlu
 * @project IntelliJ IDEA
 */
@Slf4j
@RestController
public class IndexController {
    @Resource    //通过该注解没告诉JVM，该对象需要从Spring容器里面去取
    IUserService userService;
    @Resource
    HttpServletResponse response;

    @PostMapping("login")
    public Object login(@Valid @RequestBody User user){
        JSONObject object = userService.login(user);

        return ViewUtil.json(response,200,"登陆成功",object);
    }

}

